<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="keywords" content="admin, dashboard, bootstrap, template, flat, modern, theme, responsive, fluid, retina, backend, html5, css, css3">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="image/png">

  <title>{:lang('编辑用户')}</title>
  
  <!--common-->
  <link href="/static/css/public/style.css" rel="stylesheet">
  <link href="/static/css/public/style-responsive.css" rel="stylesheet">

  <!--dynamic table-->
  <link href="/static/js/public/advanced-datatable/css/demo_page.css" rel="stylesheet" />
  <link href="/static/js/public/advanced-datatable/css/demo_table.css" rel="stylesheet" />
  <link rel="stylesheet" href="/static/js/public/data-tables/DT_bootstrap.css" />


  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <script src="js/respond.min.js"></script>
  <![endif]-->
</head>

<body class="sticky-header">
	<!-- 左侧菜单开始-->
	{include file="public/nav_left"}
    <!-- 左侧菜单结束-->
    
    <!-- main content start-->
    <div class="main-content" >

        <!-- 头部菜单开始-->
          {include file="public/nav_top"}
        <!-- 头部菜单结束-->
        
        
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                {:lang('用户管理')}
            </h3>
         
        </div>
        <!-- page heading end-->

        <!--主内容开始-->
        <div class="wrapper">
            <div class="row">
        <div class="col-sm-12">
        <section class="panel">
        <header class="panel-heading">
            {:lang('编辑用户')}
            <span class="tools pull-right">
                <a href="javascript:;" class="fa fa-chevron-down"></a>
                <!--<a href="javascript:;" class="fa fa-times"></a>-->
             </span>
        </header>
        <div class="panel-body">
        <div class="adv-table">
        
        <div class="panel-body">
                <form class="form-horizontal adminex-form" method="get">
                    <input class="form-control" id="isEdit" name="isEdit" value="{$data['id']}" type="hidden">
                    <div class="form-group">
                        <label class="col-sm-2 control-label col-lg-2">{:lang('用户名称')}</label>
                        <div class="col-lg-10">
                            <input class="form-control" id="user_name" name="user_name" value="{$data['user_name']}">
                            
                        </div>
                    </div>
                   
                    <div class="form-group">
                        <label class="col-sm-2 control-label col-lg-2">{:lang('账号名称')}</label>
                        <div class="col-lg-10">
                            <input class="form-control" id="login_name" name="login_name" value="{$data['login_name']}">
                            
                        </div>
                    </div>

                    {if condition="$data['id'] eq ''"}
                        <div class="form-group">
                            <label class="col-sm-2 control-label col-lg-2">{:lang('账号密码')}</label>
                            <div class="col-lg-10">
                                <input class="form-control" id="login_password" name="login_password" value="{$data['login_password']}">
                                
                            </div>
                        </div>
                    {else /}
                         <input class="form-control" id="login_password" name="login_password" value="123456" type="hidden">
                    {/if}

                    <div class="form-group">
                        <label class="col-sm-2 control-label col-lg-2">{:lang('关联钉钉账号')}</label>
                        <div class="col-lg-10">
                            <select class="form-control" name="dd_user_id" id="dd_user_id" >
                                <option value="0" {if condition="$data.dd_user_id eq 0"}selected{/if}>无关联</option>
                                {volist name="dd" id="item"}
                                <option value="{$item.dd_user_id}" {if condition="$data.dd_user_id eq $item.dd_user_id"}selected{/if}>{$item.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-group" >
                        <label class="col-sm-2 control-label col-lg-2">{:lang('用户权限')}</label>
                        <div class="col-lg-10" id="table">
                            {volist name="auth" key="key" id="vo"}
                                <div style="margin:10px"><input id="auth_table" type="checkbox" value="{$vo.id}" class="checkall" {if condition="isset($data['auth']) && in_array($vo['id'],$data['auth'])"}checked{/if}> &nbsp;{:lang($vo.menu_name)}</div>
                                {if condition="$auth[$key-1]['num'] neq 0"}
                                    <div style="margin:10px;padding-left:35px" id="auth_{$vo.id}">
                                        {volist name="vo['child']" key="key1" id="vo1"}
                                            <input id="auth_table" class="checkone" type="checkbox" value="{$vo1.id}" {if condition="isset($data['auth']) && in_array($vo1['id'],$data['auth'])"}checked{/if}> &nbsp;{:lang($vo1.menu_name)}&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                                        {/volist}
                                    </div>
                                {/if}
                            {/volist}
                        </div>
                        <input id="menu_auth" name="menu_auth" value="" hidden >
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-2 control-label col-lg-2">{:lang('状态')}</label>
                        <div class="col-lg-10">
                            <select class="form-control m-bot15" id="user_status" name="user_status">
                                <option value="1" <?php if($data['user_status']==1){echo "selected";} ?>>{:lang('使用中')}</option>
                                <option value="0" <?php if($data['user_status']==0){echo "selected";} ?>>{:lang('停止使用')}</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-2 control-label col-lg-2">{:lang('超级管理员')}</label>
                        <div class="col-lg-10">
                            <div class="checkbox">
                                <div class="col-lg-2" style="width:150px">
                                    <input type="radio" value="1" name="is_admin" id="is_admin" {if condition="$data['is_admin'] eq 1"}checked{/if}/>{:lang('是')}
                                </div>
                                <div class="col-lg-3" style="width:150px">
                                   <input type="radio" value="0" name="is_admin" id="is_admin" {if condition="$data['is_admin'] eq 0"}checked{/if}/>{:lang('否')}
                                </div>
                            </div>
                            
                        </div>
                    </div>
                    
                    <div class="form-group">
                          <div class="col-lg-offset-2 col-lg-10" style="text-align: center;padding-right: 300px;">
                            <button type="button" class="btn btn-primary" onClick="getEdit()">{:lang('提交')}</button>
                   			<button type="button" class="btn btn-default" onclick="history.go(-1)">{:lang('返回')}</button>
                          </div>
                       </div>
                </form>
                
               
                
                
                
        </div>
        
        <!--main begin-->
        
        
        <!--main end-->        
        
        </div>
        </div>
        </section>
        </div>
        </div>

        
        
            
        </div>
        <!--主内容结束-->


    </div>
    <!-- main content end-->

<!-- Placed js at the end of the document so the pages load faster -->
<script src="/static/js/public/jquery-1.10.2.min.js"></script>
<script src="/static/js/public/jquery-ui-1.9.2.custom.min.js"></script>
<script src="/static/js/public/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/js/public/bootstrap.min.js"></script>
<script src="/static/js/public/modernizr.min.js"></script>
<script src="/static/js/public/jquery.nicescroll.js"></script>
<script src="/static/js/public/layer.js"></script>

<!--dynamic table-->
<script src="/static/js/public/advanced-datatable/js/jquery.dataTables.js"></script>
<script src="/static/js/public/data-tables/DT_bootstrap.js"></script>
<!--dynamic table initialization -->
<script src="/static/js/public/dynamic_table_init.js"></script>

<!--common scripts for all pages-->
<script src="/static/js/public/scripts.js"></script>

<script src="/static/js/user/user.js"></script>

<script>
$(".checkall").click(function(){    
    var id = $(this).val();
	if(this.checked){    
	    $(this).attr("checked", true);
		$("#auth_"+id+" :checkbox").attr("checked", true);   
	}else{  
	    $(this).attr("checked", false);  
		$("#auth_"+id+" :checkbox").attr("checked", false); 
	}
	 
});

$(".checkone").click(function(){        
	if(this.checked){    
	    $(this).attr("checked", true);  
	}else{  
	    $(this).attr("checked", false);   
	}
});
//编辑用户
function getEdit(){
    if(!$("#user_name").val()){
        layer.msg("请填写用户名");return false;
    }
    if(!$("#login_name").val()){
        layer.msg("请填写用户登录名");return false;
    }
    if(!$("#login_password").val()){
        layer.msg("请填写用户密码");return false;
    }
    var valArr = new Array;
    $("#auth_table[checked]").each(function(i){
        valArr[i] = $(this).val();
    });
    var menu_auth = valArr.join();
    $("#menu_auth").val(menu_auth);
    var params = $("form").serialize();
    $.post("/admin/User/saveEdit",params,function(data){
        if(data.status === 1){
            layer.alert(data.msg, {
                skin: 'layui-layer-lan' //样式类名
                ,closeBtn: 1
            }, function(){
                location.href="/admin/User/getUserList/pId/1";
            });
        } else {
            layer.msg(data.msg)
        }
    })
}
</script>
</body>
</html>
